var socket = require('socket.io-client')('http://localhost:8036');
var logger = require('log4js').getLogger();
var exec = require('child_process').exec;

socket.on('connect', function () {
    logger.info("connected success");
    socket.emit('init', {
        containerId : "test"
    });
});

socket.on('exec', function (json) {
    logger.debug('data : ' + JSON.stringify(json));
    socket.emit('console', {
        type: 'exec',
        from : 'stdout',
        message: "test"
    });
    /*exec(json.command, {cwd : json.cwd}, function(error, stdout, stderr){
        if(stdout){
            socket.emit('console', {
                type: 'exec',
                from : 'stdout',
                message: stdout.toString('utf-8')
            });
        }
        if(stderr){
            socket.emit('console', {
                type: 'exec',
                from : 'stderr',
                message: stderr.toString('utf-8')
            });
        }
        if(error){
            socket.emit('agenterror', {
                type: 'exec',
                message: error
            });
        }
        socket.emit('close', {
            type: 'exec'
        });
    });*/
});
